package com.jfirer.validator.context;

import javax.validation.ConstraintValidatorContext;
import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeBuilderDefinedContext;
import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.LeafNodeContextBuilder;
import com.jfirer.validator.path.api.ConnectionNode;

public class LeafNodeContextBuilderImpl extends BaseContextInfo implements LeafNodeContextBuilder
{
    
    public LeafNodeContextBuilderImpl(String customMessageTemplate, ConnectionNode connectionNode, ConstraintValidatorContextImpl constraintValidatorContextImpl)
    {
        super(customMessageTemplate, connectionNode, constraintValidatorContextImpl);
    }
    
    @Override
    public LeafNodeBuilderDefinedContext atKey(Object key)
    {
        connectionNode.setKey(key);
        connectionNode.setInIterable(true);
        return new LeafNodeBuilderDefinedContextImpl(customMessageTemplate, connectionNode, constraintValidatorContextImpl);
    }
    
    @Override
    public LeafNodeBuilderDefinedContext atIndex(Integer index)
    {
        connectionNode.setIndex(index);
        connectionNode.setInIterable(true);
        return new LeafNodeBuilderDefinedContextImpl(customMessageTemplate, connectionNode, constraintValidatorContextImpl);
    }
    
    @Override
    public ConstraintValidatorContext addConstraintViolation()
    {
        return constraintValidatorContextImpl.addCustomConstraintViolation(connectionNode, customMessageTemplate);
    }
    
}
